var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/asyncToGenerator"), a = require("../../../http/searchApi.js");

Component({
    properties: {
        autoBanner: {
            type: Boolean,
            value: !1
        },
        placeholder: {
            type: String,
            value: "MAKE TOY FUN"
        },
        rootBackground: {
            type: String,
            value: "#f5f5f5"
        },
        showIcon: {
            type: Boolean,
            value: !0
        },
        inputEnable: {
            type: Boolean,
            value: !0
        }
    },
    data: {
        inputValue: ""
    },
    lifetimes: {
        attached: function() {
            this.loadHotSearch();
        }
    },
    methods: {
        onInput: function(e) {
            this.setData({
                inputValue: e.detail.value
            });
        },
        onClear: function() {
            this.setData({
                inputValue: ""
            }), this.triggerEvent("onClear", {});
        },
        onConfirm: function() {
            this.triggerEvent("onConfirm", this.data.inputValue);
        },
        setInputValue: function(e) {
            this.setData({
                inputValue: e
            });
        },
        bannerOnTap: function(e) {
            this.curTapText = e.currentTarget.dataset.text;
        },
        rootOnTap: function() {
            this.data.inputEnable || (this.data.bannerList || wx.navigateTo({
                url: "/pages/search/search"
            }), this.curTapText && (wx.navigateTo({
                url: "/pages/search/search?placeholder=" + this.curTapText
            }), this.curTapText = null));
        },
        loadHotSearch: function() {
            var n = this;
            return t(e.default.mark(function t() {
                var r, u;
                return e.default.wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        if (console.log("autoBanner:", n.data.autoBanner), n.data.autoBanner) {
                            e.next = 3;
                            break;
                        }
                        return e.abrupt("return");

                      case 3:
                        return e.prev = 3, e.next = 6, a.hotData();

                      case 6:
                        r = e.sent, u = (u = (u = r.data.searchWords || []).filter(function(e) {
                            return !e.activity;
                        })).map(function(e) {
                            return e.keyWord;
                        }), n.setData({
                            bannerList: u
                        }), e.next = 16;
                        break;

                      case 13:
                        e.prev = 13, e.t0 = e.catch(3), console.log("loadHotSearch:", e.t0);

                      case 16:
                        return e.prev = 16, e.finish(16);

                      case 18:
                      case "end":
                        return e.stop();
                    }
                }, t, null, [ [ 3, 13, 16, 18 ] ]);
            }))();
        }
    }
});